package com.bumptech.glide;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.load.ImageHeaderParser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import o.aat;
import o.hg.e;
import o.ry;
import o.sd;
import o.se;
import o.sl;
import o.sn;
import o.ti;
import o.ts;
import o.tx;
import o.vk;
import o.vn;
import o.vr;
import o.yc;
import o.yd;
import o.yz;
import o.zb;
import o.zc;
import o.zf;
import o.zg;
import o.zh;

public class Registry {
    private final yd ʻ = new yd();
    private final e<List<Throwable>> ʼ = aat.ˏ();
    private final zc ʽ = new zc();
    private final sn ˊ = new sn();
    private final zb ˋ = new zb();
    private final vn ˎ = new vn(this.ʼ);
    private final zg ˏ = new zg();
    private final zh ॱ = new zh();
    private final yz ॱॱ = new yz();
    private final zf ᐝ = new zf();

    public static class MissingComponentException extends RuntimeException {
        public MissingComponentException(@NonNull String str) {
            super(str);
        }
    }

    public static final class NoImageHeaderParserException extends MissingComponentException {
        public NoImageHeaderParserException() {
            super("Failed to find image header parser.");
        }
    }

    public static class NoModelLoaderAvailableException extends MissingComponentException {
        public NoModelLoaderAvailableException(@NonNull Object obj) {
            super("Failed to find any ModelLoaders for model: " + obj);
        }

        public NoModelLoaderAvailableException(@NonNull Class<?> cls, @NonNull Class<?> cls2) {
            super("Failed to find any ModelLoaders for model: " + cls + " and data: " + cls2);
        }
    }

    public static class NoResultEncoderAvailableException extends MissingComponentException {
        public NoResultEncoderAvailableException(@NonNull Class<?> cls) {
            super("Failed to find result encoder for resource class: " + cls + ", you may need to consider registering a new Encoder for the requested type or DiskCacheStrategy.DATA/DiskCacheStrategy.NONE if caching your transformed resource is unnecessary.");
        }
    }

    public static class NoSourceEncoderAvailableException extends MissingComponentException {
        public NoSourceEncoderAvailableException(@NonNull Class<?> cls) {
            super("Failed to find source encoder for data class: " + cls);
        }
    }

    public Registry() {
        ˋ(Arrays.asList(new String[]{"Gif", "Bitmap", "BitmapDrawable"}));
    }

    @NonNull
    public <Data> Registry ˋ(@NonNull Class<Data> cls, @NonNull ry<Data> ryVar) {
        this.ˋ.ˋ(cls, ryVar);
        return this;
    }

    @NonNull
    public <Data, TResource> Registry ॱ(@NonNull Class<Data> cls, @NonNull Class<TResource> cls2, @NonNull se<Data, TResource> seVar) {
        ˊ("legacy_append", cls, cls2, seVar);
        return this;
    }

    @NonNull
    public <Data, TResource> Registry ˊ(@NonNull String str, @NonNull Class<Data> cls, @NonNull Class<TResource> cls2, @NonNull se<Data, TResource> seVar) {
        this.ˏ.ˏ(str, seVar, cls, cls2);
        return this;
    }

    @NonNull
    public final Registry ˋ(@NonNull List<String> list) {
        List arrayList = new ArrayList(list.size());
        arrayList.addAll(list);
        arrayList.add(0, "legacy_prepend_all");
        arrayList.add("legacy_append");
        this.ˏ.ˎ(arrayList);
        return this;
    }

    @NonNull
    public <TResource> Registry ॱ(@NonNull Class<TResource> cls, @NonNull sd<TResource> sdVar) {
        this.ॱ.ˎ(cls, sdVar);
        return this;
    }

    @NonNull
    public Registry ॱ(@NonNull sl.e<?> eVar) {
        this.ˊ.ˋ(eVar);
        return this;
    }

    @NonNull
    public <TResource, Transcode> Registry ॱ(@NonNull Class<TResource> cls, @NonNull Class<Transcode> cls2, @NonNull yc<TResource, Transcode> ycVar) {
        this.ʻ.ˋ(cls, cls2, ycVar);
        return this;
    }

    @NonNull
    public Registry ˊ(@NonNull ImageHeaderParser imageHeaderParser) {
        this.ʽ.ˎ(imageHeaderParser);
        return this;
    }

    @NonNull
    public <Model, Data> Registry ˏ(@NonNull Class<Model> cls, @NonNull Class<Data> cls2, @NonNull vr<Model, Data> vrVar) {
        this.ˎ.ˎ(cls, cls2, vrVar);
        return this;
    }

    @NonNull
    public <Model, Data> Registry ˊ(@NonNull Class<Model> cls, @NonNull Class<Data> cls2, @NonNull vr<? extends Model, ? extends Data> vrVar) {
        this.ˎ.ˋ(cls, cls2, vrVar);
        return this;
    }

    @Nullable
    public <Data, TResource, Transcode> ts<Data, TResource, Transcode> ˊ(@NonNull Class<Data> cls, @NonNull Class<TResource> cls2, @NonNull Class<Transcode> cls3) {
        ts<Data, TResource, Transcode> tsVar = null;
        ts<Data, TResource, Transcode> ˊ = this.ॱॱ.ˊ(cls, cls2, cls3);
        if (this.ॱॱ.ˏ(ˊ)) {
            return null;
        }
        if (ˊ != null) {
            return ˊ;
        }
        List ˏ = ˏ((Class) cls, (Class) cls2, (Class) cls3);
        if (!ˏ.isEmpty()) {
            tsVar = new ts(cls, cls2, cls3, ˏ, this.ʼ);
        }
        this.ॱॱ.ॱ(cls, cls2, cls3, tsVar);
        return tsVar;
    }

    @NonNull
    private <Data, TResource, Transcode> List<ti<Data, TResource, Transcode>> ˏ(@NonNull Class<Data> cls, @NonNull Class<TResource> cls2, @NonNull Class<Transcode> cls3) {
        List<ti<Data, TResource, Transcode>> arrayList = new ArrayList();
        for (Class cls4 : this.ˏ.ˎ(cls, cls2)) {
            for (Class cls5 : this.ʻ.ॱ(cls4, cls3)) {
                arrayList.add(new ti(cls, cls4, cls5, this.ˏ.ॱ(cls, cls4), this.ʻ.ˋ(cls4, cls5), this.ʼ));
            }
        }
        return arrayList;
    }

    @NonNull
    public <Model, TResource, Transcode> List<Class<?>> ॱ(@NonNull Class<Model> cls, @NonNull Class<TResource> cls2, @NonNull Class<Transcode> cls3) {
        List<Class<?>> ˊ = this.ᐝ.ˊ(cls, cls2, cls3);
        if (ˊ != null) {
            return ˊ;
        }
        List<Class<?>> arrayList = new ArrayList();
        for (Class ˎ : this.ˎ.ˋ((Class) cls)) {
            for (Class cls4 : this.ˏ.ˎ(ˎ, cls2)) {
                if (!(this.ʻ.ॱ(cls4, cls3).isEmpty() || arrayList.contains(cls4))) {
                    arrayList.add(cls4);
                }
            }
        }
        this.ᐝ.ˊ(cls, cls2, cls3, Collections.unmodifiableList(arrayList));
        return arrayList;
    }

    public boolean ˋ(@NonNull tx<?> txVar) {
        return this.ॱ.ˏ(txVar.ˎ()) != null;
    }

    @NonNull
    public <X> sd<X> ॱ(@NonNull tx<X> txVar) throws NoResultEncoderAvailableException {
        sd<X> ˏ = this.ॱ.ˏ(txVar.ˎ());
        if (ˏ != null) {
            return ˏ;
        }
        throw new NoResultEncoderAvailableException(txVar.ˎ());
    }

    @NonNull
    public <X> ry<X> ˋ(@NonNull X x) throws NoSourceEncoderAvailableException {
        ry<X> ˊ = this.ˋ.ˊ(x.getClass());
        if (ˊ != null) {
            return ˊ;
        }
        throw new NoSourceEncoderAvailableException(x.getClass());
    }

    @NonNull
    public <X> sl<X> ˏ(@NonNull X x) {
        return this.ˊ.ˎ(x);
    }

    @NonNull
    public <Model> List<vk<Model, ?>> ˎ(@NonNull Model model) {
        List<vk<Model, ?>> ˊ = this.ˎ.ˊ(model);
        if (!ˊ.isEmpty()) {
            return ˊ;
        }
        throw new NoModelLoaderAvailableException(model);
    }

    @NonNull
    public List<ImageHeaderParser> ˋ() {
        List<ImageHeaderParser> ॱ = this.ʽ.ॱ();
        if (!ॱ.isEmpty()) {
            return ॱ;
        }
        throw new NoImageHeaderParserException();
    }
}
